﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace binary
{
    public class ConfigList
    {
        public string user { get; set; }
        public string password { get; set; }
        public string host { get; set; }
        public string dbName { get; set; }
        public List<SingleTable> tableList = new List<SingleTable>();
        public string dbfSource { get; set; }
        public string dbfDestination { get; set; }
        public string errorTable { get; set; }
        public string logTable { get; set; }
        public string finish { get; set; }

        public ConfigSingle getConfig()
        {
            ConfigSingle c = new ConfigSingle
            {
                dbName = this.dbName
                ,host = this.host
                ,password = this.password
                ,user = this.user
                , errorsTable = this.errorTable
                , logTable = this.logTable
            };
            return c;
        }

        public bool IsValid()
        {
            if (String.IsNullOrEmpty(this.user)) return false;
            if (String.IsNullOrEmpty(this.password)) return false;
            if (String.IsNullOrEmpty(this.host)) return false;
            if (String.IsNullOrEmpty(this.dbName)) return false;
            if (String.IsNullOrEmpty(this.dbfSource)) return false;
            if (String.IsNullOrEmpty(this.dbfDestination)) return false;
            if (String.IsNullOrEmpty(this.errorTable)) return false;
            if (String.IsNullOrEmpty(this.logTable)) return false;
            return true;
        }

        public string getNonValidField()
        {
            if (String.IsNullOrEmpty(this.user)) return "USER";
            if (String.IsNullOrEmpty(this.password)) return "PASSWORD";
            if (String.IsNullOrEmpty(this.host)) return "HOST";
            if (String.IsNullOrEmpty(this.dbName)) return "DBNAME";
            if (String.IsNullOrEmpty(this.dbfSource)) return "DBFSOURCE";
            if (String.IsNullOrEmpty(this.dbfDestination)) return "DBFDESTINATION";
            if (String.IsNullOrEmpty(this.errorTable)) return "ERROR";
            if (String.IsNullOrEmpty(this.logTable)) return "LOG";
            return "";
        }

    }
}
